<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <meta content="App Inventor for Android" name="description">
    <meta content="Android, Blocks App Inventor, Mobile, Phone, IDE" name="keywords">
    <title>
      TinyWebDB - App Inventor for Android
    </title>
    <link href="../../../static/images/appinventor-16.png" rel="SHORTCUT ICON" type="image/ico">
    <link href="../../../static/images/appinventor-16.png" rel="icon" type="image/png">
    <link href="../../../static/css/appinventor.css" rel="stylesheet" type="text/css">
<!-- ADD Google Analytics here -->
<!-- END Google Analytics here -->
    <style type="text/css">
img.c2 {border-width:0}
    div.c1 {clear:both;}
    </style>
  </head>
  <body>
    <div id="aiac">
      <div class="main-container">
        <div class="header">
          <div class="header-title">
            <a href="../../../about/index.html"><img alt="" src="../../../static/images/appinventor_logo.gif"></a>
          </div>
            <div class="header-search">
<!-- ADD Google Custom Search -->
<!-- END Google Custom Search -->
              <div class="header-search-query">
              </div>
              <div class="header-search-button">
              </div>
            </div>
          <div class="header-login">
            <div class="header-login-greeting">
              Learn about App Inventor
            </div>
          </div>
        </div>
        <div class="customhr customhr-green"></div>
<!-- ADD Google Search Results -->
<!-- END Google Search Results -->
        <div id="navigation">
          <div id="navigation-links">
            <div class="navigation-link-option" id="navigation-link-home">
              <a href="../../../about/index.html">About</a>
            </div>
            <div class="navigation-link-option navigation-link-active" id="navigation-link-learn">
              <a href="../../../learn/index.html">Learn</a>
            </div>
            <div class="navigation-link-option" id="navigation-link-forum">
              <a href="../../../forum/index.html">Forum</a>
            </div>
            <div class="navigation-link-option" id="navigation-link-myappinventor">
              <a href="">My Projects</a><div>(coming soon)</div>
            </div>
          </div>
          <div id="navigation-breadcrumb">
            <a href="../../../learn/index.html">Learn</a> &gt; <a href="../../../learn/reference/index.html">Reference</a> &gt; TinyWebDB &gt;
          </div>
          <div class="c1"></div>
        </div>
        <div class="customhr customhr-gray"></div>
        <div class="content">
          <div class="content-body">
            <div class="learn-page">
              <h1>
                Creating a Custom TinyWebDB Service
              </h1>
              <p>
                <span class="ButtonText">TinyWebDB</span> is an App Inventor component that allows you to store data persistently in a database on the web. Because the data is stored on the web instead of a particular phone, <span class="ButtonText">TinyWebDB</span> can be used to facilitate communication between phones and apps (e.g., multi-player games).
              </p>
              <p>
                By default, the <span class="ButtonText">TinyWebDB</span> component stores data on a test service provided by App Inventor, <a href="http://appinvtinywebdb.appspot.com/">http://appinvtinywebdb.appspot.com/</a>. This service is helpful for testing, but it is shared by all App Inventor users, and it has a limit of 1000 entries. If you use it, your data will be overwritten eventually.
              </p>
              <p>
                For most apps you write, you'll want to create a custom web service that isn't shared with other App Inventor apps and programmers. You need not be a programmer to do so-- just follow the instructions below and you'll have your own service within minutes.
              </p>
              <p>
                To create your own web service, follow these instructions:
              </p>
              <ul>
                <li>Download App Engine for Python at <a href="http://code.google.com/appengine/">http://code.google.com/appengine/</a>. After installing it, run the GoogleAppEngineLauncher by clicking its icon.
                </li>
                <li>Download this <a href="tinywebdbassets/customtinywebdb.zip">sample code</a>. It is a zip file containg the source code for your custom tinywebdb web service<br>
                </li>
                <li>Unzip the downloaded zip file. It will create a folder named <span class="ButtonText">customtinywebdb</span>. You can rename it if you want.<br>
                </li>
                <li>In the GoogleAppEngineLauncher, choose <span class="ButtonText">File | Add Existing Application</span>. Browse to set the Path to the <span class="ButtonText">customtinywebdb</span> folder you just unzipped. Then click the Run button. This will launch a test web service that runs on your local machine.
                </li>
                <li>You can test the service by opening a browser and entering "localhost:8080" as the URL. You'll see the web page interface to your web service. The end-goal of this service is to communicate with a mobile app created with App Inventor. But the service provides a web page interface to the service to help programmers with debugging. You can invoke the get and store operations by hand, view the existing entries, and also delete individual entries
                </li>
                <li>Your app is not yet on the web, and thus not yet accessible to an App Inventor app. To get it there, you need to upload it to Google's App Engine servers.
                  <ul>
                    <li>In the GoogleAppEngineLauncher, choose <span class="ButtonText">Dashboard</span>. Enter your Google account information and you'll be taken to an App Engine dashboard.
                    </li>
                    <li>Choose <span class="ButtonText">Create an Application</span>. You'll need to specify a globally unique Application Identifier. Remember the Application identifier as you'll need it later. Provide a name to your app and click <span class="ButtonText">Create Application</span> to submit. If your Identifier was unique, you now have a new, empty app on Google's servers.
                    </li>
                    <li>Open a text editor on your local computer and open the file <span class="ButtonText">app.yaml</span> within the <span class="ButtonText">customtinywebdb</span> folder you unzipped. Modify the first line so that the application matches the application identifier you set at Google.
                    </li>
                    <li>In GoogleAppEngineLauncher, choose <span class="ButtonText">Deploy</span> and follow the steps for deploying your app.
                    </li>
                  </ul>
                </li>
                <li>Test to see if your app is running on the web. In a browser, enter myapp.appspot.com, only substitute your application identifier for "myapp". The app should look the same as when you ran it on the local test server. Only now, it's on the web and you can access it from your App Inventor for Android app.
                </li>
              </ul>
              <p>
                Your App Inventor apps can store and retrieve data using your new service. Just do the following:
              </p>
              <ul>
                <li>Drag in a TinyWebDB component into the Component Designer.
                </li>
                <li>Modify the ServiceURL property from the default <a href="http://appinvtinywebdb.appspot.com/">http://appinvtinywebdb.appspot.com/</a> to your web service.
                </li>
                <li>Any StoreValue operations (blocks) will store data at your service, and any GetValue operations will retrieve from your service.<br>
                  <br>
                  <br>
                </li>
              </ul>
            </div>
          </div>
        </div>
      </div>
      <div class="footer">
        <div class="footer-legal">
          <p>
            <a href="http://creativecommons.org/licenses/by/3.0/" rel="license"><img alt="Creative Commons License" class="c2" src="http://i.creativecommons.org/l/by/3.0/88x31.png"></a><br>
            This work is licensed under a <a href="http://creativecommons.org/licenses/by/3.0/" rel="license">Creative Commons Attribution 3.0 Unported License</a> .
          </p>
          <p>
            The original work by Google has been modified<br>
              <!-- The modified work was translated from English to [language]<br> -->
            <a href="../../../about/index.html">About</a> | <a href="../../../about/privacy.html">Privacy</a> | <a href="../../../about/termsofservice.html">Terms</a>
          </p>
        </div>
        <div class="footer-lastupdate">
          <script type="text/javascript">
if (document.lastModified != '') {
                var m = "Page last updated: " + document.lastModified;
                var p = m.length-8;
                document.writeln("<center>");
                document.write(m.substring(p, 0));
                document.writeln("<\/center>");
              }
          </script>
        </div>
      </div>
    </div>
  </body>
</html>
